package saeildamil.ch18.communication;

import javax.swing.JOptionPane;

public class PrintPIThread extends Thread {
	SharedArea sharedArea;
	
	
	public PrintPIThread(SharedArea sharedArea) {
		this.sharedArea = sharedArea;
	}


	@Override
	public void run() {
		if(sharedArea.isReady!=true){	//PI가 나오지 않았다면
			synchronized (sharedArea) {
				try {
					JOptionPane.showMessageDialog(null, "PI값이 나올때까지 대기");
					sharedArea.wait();	//notify()가 올때까지 대기
				} catch (InterruptedException e) {
					System.out.println(e.getMessage());
				}
			}
		}
		JOptionPane.showMessageDialog(null, sharedArea.result);
	}
}
